import log.LogFileStream;
import log.LogItem;
import log.LogItemList;
import log.LogParserIOS;
import ui.MainFrame;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args)
    {
        doTest();

        MainFrame mainFrame = new MainFrame();
        mainFrame.create();
    }

    private static void doTest() {



    }

    

    private static void test_logStream()
    {
        LogFileStream logStream = new LogFileStream("/Volumes/code/tmp/ios.log", new LogParserIOS());

        LogItemList logList = new LogItemList();
        logList.SetEventListener(new LogItemList.EventListener() {
            @Override
            public void OnLogChanged(LogItemList host, List<LogItem> newItems) {
                ArrayList<LogItem> logList = host.getLogList();

                System.out.println("log list size = " + logList.size());
            }
        });
        logList.attachStream(logStream);

        final javax.swing.Timer timer = new javax.swing.Timer(100, new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                Timer timer = (Timer)e.getSource();
                timer.stop();

                logList.close();
            }
        });
        timer.start();
    }
}
